# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=coin3d
pkgbase=mingw-w64-${_realname}-hg
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-hg"
pkgver=r11404.a9b4869bdc0e
pkgrel=1
pkgdesc="High-level, retained-mode toolkit for effective 3D graphics development (mingw-w64)"
arch=('any')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-simage"
         "${MINGW_PACKAGE_PREFIX}-bzip2"
         "${MINGW_PACKAGE_PREFIX}-expat"
         "${MINGW_PACKAGE_PREFIX}-openal"
         #"${MINGW_PACKAGE_PREFIX}-freeglut"
         "${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-fontconfig"
         "${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("mercurial" "${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-gcc")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
url='https://bitbucket.org/Coin3D/coin'
source=("${_realname}"::"hg+https://bitbucket.org/msys2/coin"
        hg+https://bitbucket.org/msys2/generalmsvcgeneration
        hg+https://bitbucket.org/msys2/boost-header-libs-full)
options=(!strip staticlibs)
sha256sums=('SKIP'
            'SKIP'
            'SKIP')

pkgver() {
  cd "$srcdir/$_realname"
  printf "r%s.%s" "$(hg identify -n)" "$(hg identify -i)"
}

prepare() {
  cd ${srcdir}/${_realname}
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}
  ../"${_realname}"/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --disable-html \
    --disable-debug \
    --enable-system-expat \
    --enable-3ds-import \
    --disable-dl-fontconfig \
    --disable-dl-freetype \
    --disable-dl-zlib \
    --disable-dl-libbzip2 \
    --disable-dl-simage \
    --disable-dl-openal \
    --with-simage=${MINGW_PREFIX} \
    --with-openal=${MINGW_PREFIX} \
    --with-fontconfig=${MINGW_PREFIX} \
    --with-freetype=${MINGW_PREFIX} \
    --with-bzip2=${MINGW_PREFIX} \
    --with-zlib=${MINGW_PREFIX} \
    --with-simage=${MINGW_PREFIX} \
    --with-glu=${MINGW_PREFIX}/${MINGW_CHOST} \
    --without-x

    #--with-spidermonkey=no
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
